import java.util.ArrayList;
import models.BoardColumn;
import models.Event;
import models.TaskStatus;
import models.VirtualBoard;
import org.junit.*;

import controllers.Board;

import java.util.LinkedList;
import antlr.collections.List;
import play.test.UnitTest;

public class Boardtest extends UnitTest {

	/**
	 * 
	 */
	@Test
	// test the change in columns order
	public void testOrder() {
		LinkedList<BoardColumn> columns = new LinkedList<BoardColumn>();
		VirtualBoard c = new VirtualBoard(null, "project", columns);
		c.save();
		VirtualBoard x = VirtualBoard.findById(c.id);
		System.out.println(x.type);
		assertFalse(VirtualBoard.count() == 0);
		assertNotNull(x);
		TaskStatus t=new TaskStatus("inprog");
		t.save();
		BoardColumn col = new BoardColumn(0, t, "progress", null, c);
		columns.add(col);
		col.save();
		t=new TaskStatus("done");
		t.save();
		BoardColumn col2 = new BoardColumn(1, t, "done", null, c);
		columns.add(col2);
		col2.save();
		t=new TaskStatus("fixed");
		t.save();
		BoardColumn col3 = new BoardColumn(2, t, "fixe", null, c);
		columns.add(col3);
		col3.save();
		col = BoardColumn.findById(col.id);
		Board.changeColumnOrder(c.id, 2, 0);
		assertEquals(1, col.positionNumber);

	}
	/**
	 * @param eventId
	 * @param type
	 * This Method tests the viewBoard method it makes sure the board is created nd saved in the DB
	 * I call the method ViewBoard with these Parameters 
	 */
	@Test
	public  void testBoard(long eventId, String type) {
		Board.viewBoard(eventId, type);
		Event event = Event.findById(eventId); 
		assertNotNull(event.board);
		assertNotNull(event.board.columns);
		for (int i = 0 ; i < event.board.columns.size() ; i++ ) 
			assertNotNull(event.board.columns.get(i).stickNotes);
	}
}